import QtQuick 1.1
import com.nokia.symbian 1.1

PageStackWindow {
    id: window
    initialPage: mainPage
    showToolBar: true

    MainPage {
        id: mainPage
        tools: ToolBarLayout {
            visible: true
            ToolButton {
                flat: true
                iconSource: "toolbar-back"
                onClicked: window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()
            }
            ToolButton {
                flat: true
                iconSource: "toolbar-add"
                onClicked: mainPage.toggleDrawing(!mainPage.drawing);
            }
            ToolButton {
                flat: true
                iconSource: "toolbar-delete"
                onClicked: mainPage.toggleDrawing(mainPage.undo());
            }
            ToolButton {
                flat: true
                iconSource: "toolbar-view-menu"
                anchors.right: (parent === undefined) ? undefined : parent.right
                onClicked: (mainPage.menu.status === DialogStatus.Closed) ? mainPage.menu.open() : mainPage.menu.close()
            }
        }
    }

    GalleryPage{
        id: galleryPage
        tools: ToolBarLayout{
            ToolButton {
                flat: true
                iconSource: "toolbar-back"
                onClicked: window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()
            }
        }

        onImageSelected: {
            if(mainPage.drawing){
                mainPage.toggleDrawing(false);
            }

            mainPage.imageSource = image
        }
    }

    ColorChooser{
        id: colorChooser
        tools: ToolBarLayout{
            ToolButton {
                flat: true
                iconSource: "toolbar-back"
                onClicked: window.pageStack.depth <= 1 ? Qt.quit() : window.pageStack.pop()
            }
        }
        onColorSelected: mainPage.penColor = color
    }
}
